<%@page import="com.egame.manage.biz.server.cu.ManufacturerServiceImpl"%>
<%@page import="cn.egame.ext.cu.ManufactureInfo"%>
<%@page import="com.egame.manage.biz.server.gc.TerminalRecognitionServiceImpl"%>
<%@page import="com.egame.manage.biz.server.gc.TerminalServiceImpl"%>
<%@page import="cn.egame.interfaces.gc.TerminalInfo"%>
<%@page import="com.sun.xml.internal.txw2.Document"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="cn.egame.common.model.PageData"%>
<%@page import="java.util.*"%>
<%@page import="cn.egame.interfaces.gc.TerminalRecognitionInfo"%>
<%@page import="com.egame.manage.biz.server.UserServiceImpl"%>
<%@page import="com.lenovo.manager.business.domain.UserBean"%>
<%@page import="com.egame.manage.biz.utils.ConstVar"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
	List<String[]> brandMap = new ArrayList<String[]>();
	if(request.getAttribute("brandList") != null) {
		brandMap = (List<String[]>)request.getAttribute("brandList");	
	}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link type="text/css" rel="stylesheet" href="<%=request.getContextPath() %>/css/main.css"  />
<script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery-1.9.1.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		if(($("#selectManufacture").val()!=0)&&($("#selectManufacture").val()!=-1)) {
			var manu = $("#selectManufacture").val();
			$("#manufacturerId").val(manu);
		}
		if(($("#selectTerminal").val()!=0)&&($("#selectTerminal").val()!=-1)) {
			var manu = $("#selectTerminal").val();
			$("#selectTerminalId").val(manu);
		}
	});
	function URLencode(sStr) 
	{
	    return escape(sStr).replace(/\+/g, '%2B').replace(/\"/g,'%22').replace(/\'/g, '%27').replace(/\//g,'%2F');
	}
	
	function editFuc(apicode,uacode,screenpx){		
		document.getElementById("apiCode").value = apicode;
		document.getElementById("uaCode").value = uacode;
		document.getElementById("screenPx").value = screenpx;
		var actionUrl = "<%=request.getContextPath()  %>" + "/tv/terminal/edit/recognition.do";		
		document.getElementById("submitForm").setAttribute("action",actionUrl) ;
		document.getElementById("submitForm").submit();
	}
	
	function deleteFuc(apicode,uacode,screenpx){		
		document.getElementById("apiCode").value = apicode;
		document.getElementById("uaCode").value = uacode;
		document.getElementById("screenPx").value = screenpx;
		var actionUrl = "<%=request.getContextPath()  %>" + "/tv/terminal/delete/recognition.do";			
		document.getElementById("submitForm").setAttribute("action",actionUrl) ;
		document.getElementById("submitForm").submit();
	}
	
	function search(){
		document.getElementById("myform").action = "<%=request.getContextPath() + "/tv/terminal/list/recognition.do" %>";
		document.getElementById("myform").submit();
	}
</script>


<title>机型识别列表</title>
</head>
<body>
<form id="submitForm" action="" method="post">
	<input type=hidden name=apiCode id=apiCode>
	<input type=hidden name=uaCode id=uaCode>
	<input type=hidden name=screenPx id=screenPx>
</form>
<form action="" id="myform">	
<div class="matter_box">
	<h3 class="nopoint"><strong>机型识别列表</strong></h3>
	
	<% 
		int selectManufacture=-1;
		if((request.getAttribute("selectManufacture") != null)&&(Integer.parseInt(request.getAttribute("selectManufacture").toString())!=-1)) {
			selectManufacture =  Integer.parseInt(request.getAttribute("selectManufacture").toString());
		}
	%>
	<input id="selectManufacture" type="hidden" value="<%=selectManufacture %>"/>
	
	<% 
		int selectTerminal=0;
		if((request.getAttribute("selectTerminal") != null)&&(Integer.parseInt(request.getAttribute("selectTerminal").toString())!=0)) {
			selectTerminal =  Integer.parseInt(request.getAttribute("selectTerminal").toString());
		}
	%>
	<input id="selectTerminal" type="hidden" value="<%=selectTerminal %>"/>
	
	<div class="task_search">
	     <span>品牌</span>
	         <select name="selectManufacturerId" id="selectManufacturerId">
	          	<option value="-1">选择品牌</option>
          			<%  if(brandMap != null){
          					for(String[] brand:brandMap){     
          						if(brand.length==3){
          			%>          					
          					<option value="<%=brand[0] %>" <% if(brand[0].equals("" + selectManufacture)){ %>selected <%} %>><%=brand[1] %>-<%=brand[2] %></option>
          			<%	
          						}}
	          			}
          			%>
	         </select>
	         <span>机型</span>
			<select name=selectTerminalId id="selectTerminalId">
					<option value="0">请选择</option>
			<%
				List<TerminalInfo> terminallist = new ArrayList<TerminalInfo>();
				if(request.getAttribute("terminals")!=null){
					terminallist = (List<TerminalInfo>)request.getAttribute("terminals");
					for(TerminalInfo bean:terminallist){
						if(bean==null)continue;
						%>
						<option value=<%=bean.getTerminalId() %>>
							<%=bean.getTerminalName() %>--
							<%=bean.getUACode() %>
						</option>
						<%
					}
				}
			%>
				</select>       	
	       	<span>
        		<input type=button value="查询" onclick="search()" class="upload_btn">
        	</span>
	 </div>
	
	
	<p class="tr"><a class="btn2" href="<%=request.getContextPath() + "/tv/terminal/set/recognition/show.do" %>">新增</a></p>
		<div class="mt10 pt10 clearfix">
		<form id="submitForm" action=""></form>
		<table cellpadding="0" cellspacing="0" class="table2" id="rights_list">
			<tr class="first">
			<th>机型编号</th>
			<th>厂商</th>
			<th>机型</th>			
			<th>UA</th>
			<th>分辨率</th>
			<th>Model</th>
			<th>API Level</th>
			<th>是否典型机型</th>
			<th>操作人</th>
			<th>操作</th>		
		</tr>
	<%
		if(request.getAttribute("pd") != null){
			PageData pd = (PageData)request.getAttribute("pd");
			if(pd.getContent() != null){
				List<TerminalRecognitionInfo> list = (List<TerminalRecognitionInfo>)pd.getContent();
				int i=1;
				TerminalInfo terminal = null;
				ManufactureInfo manufacture = null;
				for(TerminalRecognitionInfo bean:list){	
					if(bean == null) bean = new TerminalRecognitionInfo();
					terminal = TerminalServiceImpl.getInstance().getTerminalInfo(0,0L,bean.getTerminalId());
					if(terminal == null) terminal = new TerminalInfo();
					manufacture = ManufacturerServiceImpl.getInstance().getManufactureInfo(0,0L,terminal.getManufacturerId());
					%>
					<tr>
						<td align=center><%=bean.getTerminalId() %></td>
						<td align=center><%=manufacture.getEnShort() %></td>
						<td align=center><%=terminal.getShortUA() %></td>
						<td align=center><%=terminal.getUACode() %></td>						
						<td align=center><%=bean.getScreenPx() %></td>
						<td align=center><%=bean.getUaCode() %></td>
						<td align=center><%=bean.getApiCode() %></td>
						<td align=center><%=bean.getIsTypical()==1?"是":"否" %></td>
						<td align=center><%=UserServiceImpl.getInstance().getCnNameById(bean.getOperatorId()) %></td>
						<td align=center>
							<a href="javascript:editFuc('<%=bean.getApiCode()%>','<%= bean.getUaCode() %>','<%=bean.getScreenPx() %>')">编辑</a>
							<a href="javascript:deleteFuc('<%=bean.getApiCode()%>','<%= bean.getUaCode() %>','<%=bean.getScreenPx() %>')">删除</a>
						</td>		
					</tr>
					<%
				}
			}
		}
			%>
			
		</table>
		<%@ include file="../page.in"  %>
		</div>
	</div>
</div> 
</form>
</body>
</html>